package com.bjpowernode.springboot.web.controller;

import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * CreateTime：2020/9/1 19:03
 */

@RestController
@RequestMapping("/user")
public class UserController {

    @RequestMapping("/user")
    public String getUserById(String id) {
        return "getUserById，id=" + id ;
    }

    @PostMapping("/insert")
    public String insert(@RequestParam Map map){
        return "新增：map " + map;
    }

    @GetMapping("/select")
    public String select(@RequestParam String id){
        return "通过id: " + id + "进行查询";
    }

    @PutMapping("/update")
    public String update(@RequestBody Map map){
        return "修改：map " + map;
    }

    @DeleteMapping("/delete")
    public String delete(@RequestParam String id){
        return "通过id：" + id + "进行删除";
    }


    //=====================================RESTFul风格=====================================================
    @PostMapping("/{id}")
    public String updateUser(@PathVariable String id){
        return "updateUser， id=" + id;
    }

    @GetMapping("/{id}")
    public String getUser(@PathVariable String id){
        return "getUser， id=" + id;
    }

    @PutMapping("/{id}")
    public String insertUser(@PathVariable String id){
        return "insertUser， id=" + id;
    }

    @DeleteMapping("/{id}")
    public String deleteUser(@PathVariable String id){
        return "deleteUser， id=" + id;
    }
}
